package com.linwen.excise.leetcode;

import java.util.Arrays;

/**
 * @ClassName _977有序数组的平方
 * @Description 有序数组的平方
 * @Author lin
 * @Date 2021/11/8 下午9:21
 * @Version V1.0
 */
public class _977有序数组的平方 {
    public static void main(String[] args) {
        int[] arr = new int[]{-4,-1,0,3,10};
        sortedSquares(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static int[] sortedSquares(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            nums[i] = nums[i]*nums[i];
        }
        Arrays.sort(nums);
        return nums;
    }
}
